package quanlydoanra.themmoi;

import java.util.ArrayList;
import java.util.HashMap;

import dbutil.ConnectDB;

public class MucDich {
	private int id;
	private String linhvuc;
	private String mucdich;
	public MucDich(){}
	public int getId() {
		return id;
	}
		
	public MucDich(int id, String mucdich) {
		super();
		this.id = id;
		this.mucdich = mucdich;
	}
	public MucDich(String linhvuc, String mucdich) {
		this.linhvuc = linhvuc;
		this.mucdich = mucdich;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getLinhvuc() {
		return linhvuc;
	}
	public void setLinhvuc(String linhvuc) {
		this.linhvuc = linhvuc;
	}
	public String getMucdich() {
		return mucdich;
	}
	public void setMucdich(String mucdich) {
		this.mucdich = mucdich;
	}
	public int timLinhVuc(){
		
		try{
		String sql1 = "select * from mucdich where linhvuc like '"+this.linhvuc+"' and mucdich like '"+this.mucdich+"'";
		System.out.println("Linh Vuc va muc dich "+this.linhvuc+" ;"+this.mucdich);
		System.out.println("SQL "+sql1);
		ArrayList arr = ConnectDB.getDataTypeList(sql1);
		HashMap<String, Object> hash = (HashMap<String, Object>) arr.get(0);
		int id = Integer.parseInt(hash.get("id").toString());
		System.out.println("id muc dich "+id);
		this.id = id;
		}
		catch(Exception ex){
			System.out.println("loi o muc dich");
		}
		return this.id;
	}
	public static void main(String[] args) {
		MucDich d = new MucDich();
		d.setLinhvuc("Giáo dục - đào tạo");
		d.setMucdich("Hợp tác đào tạo");
		System.out.println("so id "+d.timLinhVuc());
	}
	

}
